
// Full Sample
clear all
set mem 50m
* cd "..."
use "DATA_COMPILED_ATOP_20151118.dta"
set more off 

label var interaction "Troops $\times$ Troops Spatial Mean"
label var meanregionalallies "Host-State Allies (Spatial Mean)"
label var meanregionalusallies "US Allies (Spatial Mean)"

xtset ccode year
set more off
eststo clear

	//	All States
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity l.growth ///
	l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if year<2004 , corr(ar1) pairwise 
	estimates store model1 
	// 	Non-NATO US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates ///
	civilwar l.meanregionalallies l.meanregionalusallies if usally == 1 & NATO == 0 ///
	& year<2004, corr(ar1) pairwise 
	estimates store model2 
	//	NATO Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity  ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if NATO == 1 & year<2004 , ///
	corr(ar1) pairwise
	estimates store model3 
	// 	Non-US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if usally ==0 & year<2004 , ///
	corr(ar1) pairwise 
	estimates store model4 
	
* Cold War Only
//	All States
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity l.growth ///
	l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if year<1991 , corr(ar1) pairwise 
	estimates store cwmodel1 
	// 	Non-NATO US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates ///
	civilwar l.meanregionalallies l.meanregionalusallies if usally == 1 & NATO == 0 ///
	& year<1991, corr(ar1) pairwise 
	estimates store cwmodel2 
	//	NATO Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity  ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if NATO == 1 & year<1991 , ///
	corr(ar1) pairwise
	estimates store cwmodel3 
	// 	Non-US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if usally ==0 & year<1991 , ///
	corr(ar1) pairwise 
	estimates store cwmodel4 
	

* Post-Cold War Only
//	All States
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity l.growth ///
	l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if year>=1991 , corr(ar1) pairwise 
	estimates store pcwmodel1 
	// 	Non-NATO US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates ///
	civilwar l.meanregionalallies l.meanregionalusallies if usally == 1 & NATO == 0 ///
	& year>=1991, corr(ar1) pairwise 
	estimates store pcwmodel2 
	//	NATO Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity  ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if NATO == 1 & year>=1991, ///
	corr(ar1) pairwise
	estimates store pcwmodel3 
	// 	Non-US Allies
xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity ///
	l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar ///
	l.meanregionalallies l.meanregionalusallies if usally ==0 & year>=1991, ///
	corr(ar1) pairwise 
	estimates store pcwmodel4

	

* Full Sample Models

	coefplot (model1, label(Pooled Model) msym(S) mfcolor(white) ) (model2, label(Non-NATO Allies) msym(O) mfcolor(white)) (model3, label(NATO Allies) msym(D) mfcolor(white)) (model4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.meanregionalallies L.meanregionalusallies) ///
	xline(0) coeflabels(L.meanregionalallies = "Host-State Allies Spatial Mean" L.meanregionalusallies = "US Allies Spatial Mean" , wrap(20) notick) ///
	legend(ring(1) pos(3) cols(1)) ///
	msize(1.75) mlwidth(.25) ///		
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(2)") 
		graph export "coefficient_plot.pdf", replace
		graph save coef1.gph, replace

	coefplot (model1, label(Pooled Model) msym(S) mfcolor(white) ) (model2, label(Non-NATO Allies) msym(O) mfcolor(white)) (model3, label(NATO Allies) msym(D) mfcolor(white)) (model4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.spatial_lag) ///
	xline(0) coeflabels(L.spatial_lag = "Defense Burden Spatial Lag", wrap(20) notick) ///
	legend(ring(1) pos(3) ) ///
	msize(1.75) mlwidth(.25) ///
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(1)") 
		graph export "coefficient_plot_2.pdf", replace
		graph save coef2.gph, replace
		
		grc1leg coef2.gph coef1.gph , cols(2) legendfrom(coef1.gph) pos(3) iscale(*1.2)  name(biggraph, replace)
		graph display biggraph, xsize(10) ysize(5)
		graph export "coefficient_plot_4.pdf", replace

		
* Cold War Sample Models

	coefplot (cwmodel1, label(Pooled Model) msym(S) mfcolor(white) ) (cwmodel2, label(Non-NATO Allies) msym(O) mfcolor(white)) (cwmodel3, label(NATO Allies) msym(D) mfcolor(white)) (cwmodel4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.meanregionalallies L.meanregionalusallies) ///
	xline(0) coeflabels(L.meanregionalallies = "Host-State Allies Spatial Mean" L.meanregionalusallies = "US Allies Spatial Mean" , wrap(20) notick) ///
	legend(ring(1) pos(3) cols(1)) ///
	msize(1.75) mlwidth(.25) ///
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(2)") 
		graph export "cwcoefficient_plot_cw1.pdf", replace
		graph save coef1.gph, replace

	coefplot (cwmodel1, label(Pooled Model) msym(S) mfcolor(white) ) (cwmodel2, label(Non-NATO Allies) msym(O) mfcolor(white)) (cwmodel3, label(NATO Allies) msym(D) mfcolor(white)) (cwmodel4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.spatial_lag) ///
	xline(0) coeflabels(L.spatial_lag = "Defense Burden Spatial Lag", wrap(20) notick) ///
	legend(ring(1) pos(3) ) ///
	msize(1.75) mlwidth(.25) ///
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(1)") 
		graph export "coefficient_plot_cw2.pdf", replace
		graph save coef2.gph, replace
		
		grc1leg coef2.gph coef1.gph , cols(2) legendfrom(coef1.gph) pos(3) iscale(*1.2)  name(biggraph, replace)
		graph display biggraph, xsize(10) ysize(5)
		graph export "coefficient_plot_cw.pdf", replace
		
		
* Post-Cold War Sample Models

	coefplot (pcwmodel1, label(Pooled Model) msym(S) mfcolor(white) ) (pcwmodel2, label(Non-NATO Allies) msym(O) mfcolor(white)) (pcwmodel3, label(NATO Allies) msym(D) mfcolor(white)) (pcwmodel4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.meanregionalallies L.meanregionalusallies) ///
	xline(0) coeflabels(L.meanregionalallies = "Host-State Allies Spatial Mean" L.meanregionalusallies = "US Allies Spatial Mean" , wrap(20) notick) ///
	legend(ring(1) pos(3) cols(1)) ///
	msize(1.75) mlwidth(.25) ///
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(2)") 
		graph export "coefficient_plot_pcw1.pdf", replace
		graph save coef1.gph, replace

	coefplot (pcwmodel1, label(Pooled Model) msym(S) mfcolor(white) ) (pcwmodel2, label(Non-NATO Allies) msym(O) mfcolor(white)) (pcwmodel3, label(NATO Allies) msym(D) mfcolor(white)) (pcwmodel4, label(Non-Allies) msym(T) mfcolor(white)), keep(L.spatial_lag) ///
	xline(0) coeflabels(L.spatial_lag = "Defense Burden Spatial Lag", wrap(20) notick) ///
	legend(ring(1) pos(3) ) ///
	msize(1.75) mlwidth(.25) ///
	xtitle(Coefficient Value) ///
	ciopts(lwidth(.75 .35) lcolor()) ///
		levels(90 95) ///
		grid(between glcolor(black) glpattern(solid)) ///
		xlab()  title("(1)") 
		graph export "coefficient_plot_pcw2.pdf", replace
		graph save coef2.gph, replace
		
		grc1leg coef2.gph coef1.gph , cols(2) legendfrom(coef1.gph) pos(3) iscale(*1.2)  name(biggraph, replace)
		graph display biggraph, xsize(10) ysize(5)
		graph export "coefficient_plot_pcw.pdf", replace

